Next: Hiding #ifdef lines, Previous: Automatic indentation, Up: Common requests [Contents][Index]
Call show-paren-mode in your .emacs
file:
(show-paren-mode 1)
You can also enable this mode by selecting the ‘Paren Match Highlighting’ option from the ‘Options’ menu of the Emacs menu bar at the top of any Emacs frame.
Alternatives to this mode include:
forward-sexp) and
C-M-b (backward-sexp) will skip over
one set of balanced parentheses, so you can see which
parentheses match. (You can train it to skip over balanced
brackets and braces at the same time by modifying the syntax
table.)vi. In addition,
if the cursor isn’t over a parenthesis, it simply
inserts a % like normal.
;; By an unknown contributor
(global-set-key "%" 'match-paren)
(defun match-paren (arg)
"Go to the matching paren if on a paren; otherwise insert %."
(interactive "p")
(cond ((looking-at "\\s(") (forward-list 1) (backward-char 1))
((looking-at "\\s)") (forward-char 1) (backward-list 1))
(t (self-insert-command (or arg 1)))))